<?php use_helper('I18N'); ?>
<style type="text/css">
p img {
    background: none repeat scroll 0 0 white;
    border: 1px solid #BBBBBB;
    margin: 7px 14px 7px 0;
    padding: 5px;
    height: 50px;
    /*width: 160px;*/
}
.estimateShippinhCost th {
    -moz-border-bottom-colors: none;
    -moz-border-image: none;
    -moz-border-left-colors: none;
    -moz-border-right-colors: none;
    -moz-border-top-colors: none;
    border-color: #E1E1E1 #E1E1E1 #E1E1E1 -moz-use-text-color;
    border-style: solid solid solid none;
    border-width: 1px 1px 1px medium;
    padding: 5px;
    text-align: center;
}
.estimateShippinhCost td {
    border-bottom: 1px solid #E1E1E1;
    border-right: 1px solid #E1E1E1;
    padding: 5px;
    text-align: center;
}
</style>


<script type="text/javascript">
$(function() {
    $("#estimateShipping").click(function(event){
        event.preventDefault();
        $("#dgEstimateShippingCost").dialog("open");
    });

    $("#dgEstimateShippingCost").dialog("destroy");
    $("#dgEstimateShippingCost").dialog({
        autoOpen : false,
        modal : true,
        resizable : false,
        show: 'slide',
        hide: 'clip',
        width: 400,
        buttons: {
            "<?php echo __('Close') ?>": function() {
                $(this).dialog('close');
            }
        },
        open: function() {

        },
        close: function() {

        }
    });
})
</script>
<div id="content">

<!-- ========== CATEGORIES TABS ========= -->
<!-- ==================================== -->
<table id="contentMainWrapper" border="0" cellpadding="0" cellspacing="0" width="100%">
<tbody>
<tr>
<td id="column-left" style="width: 215px;">
    <div style="width:215px;">
        <!--// bof: categories //-->
        <div class="box" id="categories" style="width:215px;">
            <div class="box-border">
                <div class="box-head">
                    <?php echo __('Categories') ?>
                </div>
                <div class="box-body">
                    <?php include_component('component', 'categoriesSideMenu') ?>
                </div>
            </div>
        </div>
        <!--// eof: categories //-->
        <!--// bof: specials //-->
        <div class="box" id="specials" style="width:215px;">
            <div class="box-border">
                <div class="box-head">
                    <a href="<?php echo url_for("/product/specialItem") ?>"><?php echo __('Specials') ?></a>
                </div>
                <div class="box-body">
                    <?php include_component('component', 'specialsSideMenu', array('param' => 'will implement for categoryType')) ?>
                </div>

            </div>
        </div>
        <!--// eof: specials //-->
    </div>
</td>
<td id="column-center" valign="top">

    <div class="column-center-padding">

        <div class="centerColumn" id="shoppingCartDefault">

            <h1 id="cartDefaultHeading"><?php echo __('Your Shopping Cart Contents') ?></h1>

            <form name="shoppingCartForm"
                  action="/shoppingcart/doShoppingcart"
                  method="post">

                <div class="cartTotalsDisplay important">
                    <?php echo __('Total Items') ?>: <?php echo $totalItems ?>&nbsp;&nbsp;
                </div>
                <br class="clearBoth">

                <table id="cartContentsDisplay" border="0" cellpadding="0" cellspacing="0" width="100%">
                    <tbody>
                    <tr class="tableHeading">
                        <th scope="col" id="scQuantityHeading"><?php echo __('Qty') ?></th>
                        <th scope="col" id="scProductsHeading"><?php echo __('Item Name') ?></th>
                        <th scope="col" id="scUnitHeading"><?php echo __('Unit') ?></th>
                        <th scope="col" id="scTotalHeading"><?php echo __('Total') ?></th>
<!--                        <th scope="col" id="">&nbsp;</th>-->
                        <th scope="col" id="scRemoveHeading">&nbsp;</th>
                    </tr>
                    <!-- Loop through all products /-->

                    <?php
                        $totalAmountInCart = 0;
                        foreach ($cmsProducts as $cmsProduct):
                            $title = $cmsProduct->getProductName() . " #" . $cmsProduct->getProductCode();
                            if ($sf_user->getCulture() == "cn") {
                                $title = $cmsProduct->getProductNameCn() . " #" . $cmsProduct->getProductCode();
                            }
                    ?>
                    <tr class="rowEven">
                        <td class="cartQuantity">
                            <input name="cart_quantity[]" value="<?php echo $cmsProduct->getQtyInCart();?>" size="4" type="text">
                            <br>
                            <span class="alert bold"></span>
                            <br><br>
                        </td>
                        <td class="cartProductDisplay">
                            <a href="<?php echo url_for("/product/item?id=" . $cmsProduct->getProductId()) ?>">
                                <span id="cartImage" class="back">
                                    <img src="/uploads/products/<?php echo $cmsProduct->getProductPhoto() ?>" alt="<?php echo $title; ?>" title="<?php echo $title; ?>" height="177" width="177">
                                </span>
                                <span id="cartProdTitle"><?php echo $title; ?>
                                <span class="alert bold"></span></span>
                            </a>
                            <br class="clearBoth">
                        </td>
                        <td class="cartUnitDisplay price">RM <?php echo number_format($cmsProduct->getPrice(),2);?></td>
                        <td class="cartTotalDisplay">RM <?php echo number_format($cmsProduct->getTotalAmount(),2); $totalAmountInCart += $cmsProduct->getTotalAmount();?></td>
                        <td class="cartRemoveItemDisplay" style="vertical-align: top;">
                            <a href="<?php echo url_for("/shoppingcart/removeProduct?productId=".$cmsProduct->getProductId()) ?>">
                                <ul class="ui-widget ui-helper-clearfix">
                                    <li class="ui-state-default ui-corner-all" style="padding: 4px;">
                                        <span class="ui-icon ui-icon-trash"></span>
                                    </li>
                                </ul>
                            </a>
                        </td>
                        <!--<td class="cartRemoveItemDisplay" style="vertical-align: top;">
                            <br>
                            <input name="cart_delete[]" value="<?php /*echo $cmsProduct->getProductId();*/?>" type="checkbox">
                        </td>-->
                    </tr>
                    <?php endforeach; ?>
                    <!-- Finished loop through all products /-->
                    </tbody>
                </table>

                <div id="cartSubTotal">Sub-Total: <span class="price">RM<?php echo number_format($totalAmountInCart,2);?></span></div>
                <br class="clearBoth">

                <!--bof shopping cart buttons-->
                <div class="buttonRow forward">
                    <a href="<?php echo url_for("/checkout/shipping") ?>" style="text-decoration: none">
                    <img src="/images/buttons/arrow-right.png"
                         alt="<?php echo __('Go to checkout') ?>"
                         title="<?php echo __('Go to checkout') ?>">&nbsp;<strong><?php echo __('Go to checkout') ?></strong></a>
                </div>
                <div class="buttonRow back">
                    <a href="<?php echo url_for("/product/index?p=products_new") ?>" style="text-decoration: none">
                    <img src="/images/buttons/arrow-right.png"
                         alt="<?php echo __('Back to shopping') ?>"
                         title="<?php echo __('Back to shopping') ?>">&nbsp;<strong><?php echo __('Back to shopping') ?></strong></a>
                </div>

                <!--eof shopping cart buttons-->
            </form>

            <br class="clearBoth">
            <div class="buttonRow back">
                <a href="#" style="text-decoration: none" id="estimateShipping">
                <img src="/images/buttons/arrow-right.png"
                     alt="<?php echo __('Estimate shipping') ?>"
                     title="<?php echo __('Estimate shipping') ?>">&nbsp;<strong><?php echo __('Estimate shipping') ?></strong></a>
            </div>
        </div>
        <div class="clear"></div>
    </div>
</td>
</tr>
</tbody>
</table>

</div>

<script type="text/javascript">
    <?php
        echo "$('#disp_order').val('" . $sorting . "')";
    ?>
</script>

<!--    Modal for delivery group    -->
<div id="dgEstimateShippingCost" title="<?php echo __('Estimate Shipping Costs') ?>" style="display:none;">
    <table cellspacing="5" style="border: 1px solid #E1E1E1; width: 100%" class="estimateShippinhCost">
        <tbody>
            <tr class="tableHeading">
                <th class="text"><label><?php echo __('Shipping method') ?></label></th>
                <th class="text"><label><?php echo __('Charges (RM)') ?></label></th>
            </tr>


            <?php
                foreach ($deliveryGroups as $deliveryGroup):
            ?>
            <tr>
                <td class="text"><?php echo $deliveryGroup->getDeliveryName() ?></td>
                <td class="text"><?php echo $deliveryGroup->getDeliveryCharge() ?></td>
            </tr>
            <?php
                endforeach;
            ?>
            <tr>
                <td class="text"><?php echo __('Self delivery') ?></td>
                <td class="text">
                    <?php echo $customerAddress->getValue(); ?>
                    <?php //echo str_replace("\n", "<br>", $customerAddress->getValue()); ?>
                </td>
            </tr>
        </tbody>
    </table>
</div>